﻿
Public Class Oferta : Implements IEquatable(Of Oferta)
    Private _Nombre As String
    Private _Cantidad As Integer
    Private _Producto As String
    Private _Precio As Decimal
    Public Property Fecha As Date

    Public Property Producto As String
        Get
            Return _Producto
        End Get
        Set(value As String)
            Dim Gestion As New GestionProductos
            Dim sino As Boolean = False
            Dim miproducto As New Producto
            miproducto.Nombre = value
            If Gestion.Productos.Contains(miproducto) Then
                _Producto = value
            Else
                _Producto = "Error"
            End If

        End Set
    End Property
    Public Property Nombre As String
        Get
            Return _Nombre
        End Get
        Set(value As String)
            If value.Length < 2 Then
                _Nombre = "Error"
            Else
                _Nombre = value
            End If
        End Set
    End Property
    Public Property Cantidad As Integer
        Get
            Return _Cantidad
        End Get
        Set(value As Integer)
            If value <= 0 Then
                _Cantidad = 1
            ElseIf value > 5 Then
                _Cantidad = 5
            Else
                _Cantidad = value
            End If
        End Set
    End Property
    Public Property Precio As Decimal
        Get
            Return _Precio
        End Get
        Set(value As Decimal)
            If value < 0 Then
                _Precio = 0
            Else
                _Precio = value
            End If
        End Set
    End Property
    Public Sub New(ByVal producto As String, ByVal nombre As String, ByVal precio As Decimal, ByVal cantidad As Integer, ByVal fecha As Date)
        Me.Producto = producto
        Me.Nombre = nombre
        Me.Precio = precio
        Me.Cantidad = cantidad
        Me.Fecha = fecha
    End Sub
    Public Overloads Function Equals(ByVal other As Oferta) As Boolean Implements System.IEquatable(Of Oferta).Equals
        Return other IsNot Nothing AndAlso Me.Fecha = other.Fecha
    End Function
    Public Sub New()

    End Sub
End Class
